<template>
  <div>
    <h1>添加餐厅</h1>
    <el-form :model="restaurant" label-width="120px">
      <el-form-item label="名称">
        <el-input v-model="restaurant.name"></el-input>
      </el-form-item>
      <el-form-item label="地址">
        <el-input v-model="restaurant.address"></el-input>
      </el-form-item>
      <el-form-item label="评分">
        <el-rate v-model="restaurant.rating" show-score allow-half></el-rate>
      </el-form-item>
      <el-form-item label="评论">
        <el-input type="textarea" v-model="restaurant.comments"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'AddRestaurant',
  data() {
    return {
      restaurant: {
        name: '',
        address: '',
        rating: null,
        comments: ''
      }
    };
  },
  methods: {
    submitForm() {
      console.log('Submit form:', this.restaurant);
      // 提交表单逻辑
      this.$router.push({ name: 'RestaurantList' });
    },
    resetForm() {
      this.restaurant = {
        name: '',
        address: '',
        rating: null,
        comments: ''
      };
    }
  }
};
</script>

<style scoped>
h1 {
  font-size: 24px;
  color: #333;
}
</style>